package com.ruibang.glass.produce.controller.system;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.produce.domain.req.GlassIdTrackReq;
import com.ruibang.glass.produce.entity.GlassBind;
import com.ruibang.glass.produce.service.GlassIdTrackService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-03-13  19:10
 * @Description: TODO
 * @Version: 1.0
 */

@Api(tags = "玻璃ID跟踪控制器")
@RestController
@RequestMapping("/api/glass/produce/glassIdTrack")
public class GlassIdTrackController {

    @Autowired
    private GlassIdTrackService glassIdTrackService;

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页查询玻璃ID跟踪", notes = "分页查询玻璃ID跟踪")
    public ResultBody<IPage<GlassBind>> pageQuery(@RequestBody GlassIdTrackReq glassIdTrackReq) {
        return ResultBody.success(glassIdTrackService.pageQuery(glassIdTrackReq));
    }

    @PostMapping("/getDetail")
    @ApiOperation(value = "根据玻璃ID查询流程详情", notes = "根据玻璃ID查询流程详情")
    public ResultBody getDetail(String glassId, String serialNumber) {
        return ResultBody.success(glassIdTrackService.getDetail(glassId, serialNumber));
    }

    @PostMapping("/export")
    @ApiOperation(value = "数据导出", notes = "数据导出")
    public void export(@RequestBody GlassIdTrackReq glassIdTrackReq, HttpServletResponse response) {
        glassIdTrackService.export(glassIdTrackReq, response);
    }
}
